import 'package:flutter/material.dart';
import 'package:module/const.dart';
import 'package:module/home_page.dart';
import 'package:module/wallet_page.dart';
import 'package:module/zhuji_page.dart';

class MePage extends StatefulWidget {
  const MePage({super.key});

  @override
  State<MePage> createState() => _MePageState();
}

class _MePageState extends State<MePage> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: mScreenHeight,
      child: Stack(
        children: [
          Image.asset(
            'assets/my_background.png',
          ),
          Positioned(
            right: 20,
            top: 40,
            child: Container(
                width: 50,
                height: 50,
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(25),
                    color: Colors.black.withOpacity(.5)),
                child: Image.asset(
                  'assets/icon_setting.png',
                  width: 18,
                  height: 18,
                )),
          ),
          Positioned(
            bottom: 0,
            child: Stack(
              clipBehavior: Clip.none,
              children: [
                Container(
                  width: mScreenWidth,
                  height: mScreenHeight * 0.64,
                  padding: EdgeInsets.symmetric(horizontal: 20),
                  decoration: BoxDecoration(
                      color: Constants.bgColor,
                      borderRadius: BorderRadius.circular(20)),
                  child: Column(
                    children: [
                      SizedBox(
                        height: 90,
                      ),
                      Container(
                        decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.circular(10)),
                        child: Padding(
                          padding: const EdgeInsets.all(20.0),
                          child: Column(
                            children: [
                              GestureDetector(
                                onTap: () {
                                  Navigator.push(context,
                                      MaterialPageRoute(builder: (context) {
                                    return WalletPage();
                                  }));
                                },
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Row(
                                      children: [
                                        Image.asset(
                                          'assets/icon_wallet.jpg',
                                          width: 28,
                                        ),
                                        SizedBox(
                                          width: 10,
                                        ),
                                        Text(
                                          '我的钱包',
                                          style: TextStyle(fontSize: 20),
                                        )
                                      ],
                                    ),
                                    Row(
                                      children: [
                                        Text(
                                          money1.toString(),
                                          style: TextStyle(fontSize: 20),
                                        ),
                                        Image.asset('assets/icon_forward.png')
                                      ],
                                    ),
                                  ],
                                ),
                              ),
                              const Padding(
                                padding: EdgeInsets.symmetric(vertical: 10),
                                child: Divider(),
                              ),
                              Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: [
                                  Row(
                                    children: [
                                      Image.asset(
                                        'assets/icon_collect.png',
                                        width: 28,
                                      ),
                                      SizedBox(
                                        width: 10,
                                      ),
                                      Text(
                                        '我的收藏',
                                        style: TextStyle(fontSize: 20),
                                      )
                                    ],
                                  ),
                                  Image.asset('assets/icon_forward.png'),
                                ],
                              ),
                              const Padding(
                                padding: EdgeInsets.symmetric(vertical: 10),
                                child: Divider(),
                              ),
                              GestureDetector(
                                onTap: () {
                                  // Navigator.of(context).pop();
                                  Navigator.push(context,
                                      MaterialPageRoute(builder: (context) {
                                    return ZhujiPage();
                                  }));
                                },
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Row(
                                      children: [
                                        Image.asset(
                                          'assets/icon_footprint.png',
                                          width: 28,
                                        ),
                                        SizedBox(
                                          width: 10,
                                        ),
                                        Text(
                                          '我的足迹',
                                          style: TextStyle(fontSize: 20),
                                        )
                                      ],
                                    ),
                                    Image.asset('assets/icon_forward.png'),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                      SizedBox(
                        height: 15,
                      ),
                      GestureDetector(
                        onTap: () {
                          showDialog(
                              context: context,
                              builder: (BuildContext context) {
                                return Dialog(
                                  elevation: 0,
                                  shape: RoundedRectangleBorder(
                                    borderRadius: BorderRadius.circular(20.0),
                                  ),
                                  child: Container(
                                    padding: EdgeInsets.only(top: 20),
                                    height: 200,
                                    child: Column(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: [
                                        Text(
                                          '退出登录',
                                          style: TextStyle(
                                              fontWeight: FontWeight.bold,
                                              fontSize: 18),
                                        ),
                                        Text(
                                          '确认退出登录吗？',
                                          style: TextStyle(fontSize: 18),
                                        ),
                                        Row(
                                          children: [
                                            Expanded(
                                                flex: 1,
                                                child: GestureDetector(
                                                  onTap: () {
                                                    Navigator.of(context).pop();
                                                  },
                                                  child: Container(
                                                    height: 50,
                                                    decoration: BoxDecoration(
                                                        border: Border.all(
                                                            width: 1,
                                                            color:
                                                                Colors.grey)),
                                                    child: const Center(
                                                      child: Text(
                                                        '取消',
                                                        style: TextStyle(
                                                            fontSize: 18,
                                                            color: Colors.grey),
                                                      ),
                                                    ),
                                                  ),
                                                )),
                                            Expanded(
                                                flex: 1,
                                                child: GestureDetector(
                                                  onTap: () {
                                                    Navigator.push(context,
                                                        MaterialPageRoute(
                                                            builder: (context) {
                                                      return HomePage();
                                                    }));
                                                  },
                                                  child: Container(
                                                    height: 50,
                                                    decoration: BoxDecoration(
                                                        border: Border.all(
                                                            width: 1,
                                                            color:
                                                                Colors.grey)),
                                                    child: const Center(
                                                      child: Text(
                                                        '确认',
                                                        style: TextStyle(
                                                            fontSize: 18,
                                                            color: Color(
                                                                0xFFF98B31)),
                                                      ),
                                                    ),
                                                  ),
                                                )),
                                          ],
                                        )
                                      ],
                                    ),
                                  ),
                                );
                              });
                        },
                        child: Container(
                          height: 50,
                          decoration: BoxDecoration(
                              color: Colors.white,
                              borderRadius: BorderRadius.circular(10)),
                          child: Center(
                            child: Text(
                              '退出登录',
                              style: TextStyle(fontSize: 20),
                            ),
                          ),
                        ),
                      )
                    ],
                  ),
                ),
                Positioned(
                  top: -30,
                  left: 20,
                  child: Row(
                    children: [
                      Container(
                        width: 100,
                        height: 100,
                        child: Image.asset('assets/icon_scenic_avatar.png'),
                      ),
                      SizedBox(
                        width: 20,
                      ),
                      Text(
                        '用户名',
                        style: TextStyle(fontSize: 24),
                      )
                    ],
                  ),
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
